package com.yanzhiyi.user.feign;

import com.yanzhiyi.user.entity.PageResult;
import com.yanzhiyi.user.entity.Result;
import com.yanzhiyi.user.pojo.Role;
import com.yanzhiyi.user.pojo.SearchCondition;
import feign.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient(name="users")
public interface RoleFeign {

    /**
     * 分页和多条件查询  使用
     * @param name
     * @param start
     * @param size
     * @return
     */
    @PostMapping(value="/role/searchPage",consumes = "application/json")
    public Result<PageResult<Role>> searchPage(@RequestParam(value = "name",required = false) String name, @RequestParam("start") int start, @RequestParam("size") int size);

    /**
     * 添加角色  使用
     * @param role
     * @return
     */
    @PostMapping("/role/add")
    public Result add(@RequestBody Role role,@RequestParam("menus") Integer [] menus,@RequestParam("permissionIds") Integer [] permissionIds);


    /**
     * 修改角色  使用
     * @param role
     * @return
     */
    @PostMapping("/role/update")
    public Result update(@RequestBody  Role role,@RequestParam("menus") Integer [] menus,@RequestParam("permissionIds") Integer [] permissionIds);


    /**
     * 删除角色  使用
     * @param id
     * @return
     */
    @PostMapping("/role/delete")
    public Result delete(@RequestParam("id") Integer id) ;



    /**
     * 根据id 查询角色  使用
     * @param id
     * @return
     */
    @PostMapping("/role/findById")
    public Result<Map<String,Object>>  findById(@RequestParam("id") Integer id);

    /**
     * 获取所有角色
     * @param
     * @return  角色列表
     */
    @GetMapping("/role/findAll")
    public Result<List<Role>> findAll();



}
